2、Lidar avoiding

Function package:~/transbot_ws/src/transbot_laser

Introduction of lidar obstacle avoidance:

-Set lidar detection angle and response distance -After turning on the trolley, the trolley drives in a straight line without obstacles

-Determine the direction of obstacles appearing in the car (front left, front right, straight ahead) -Respond to the position of the obstacle in the car (turn left, turn right, turn left in a big circle, turn right in a big circle)

2.1、Instructions

Start up

Dynamic debugging parameters

image-20210914163944663

Parameter analysis:

ParameterRangeAnalysis
【linear】【0.0,0.45】Linear speed of robot
【angular】【0.0,2.0】Angular speed of robot
【LaserAngle】【10,180】Lidar detection angle (angle of left and right side)
【ResponseDist】【0.0,8.0】Robot response distance
【switch】【False,True】Robot movement【start/pause】

[Switch] Click the box in front of [switch], the value of [switch] is True, and the car will stop. [Switch] The default is False, and the car moves.

View node

image-20210914164552797

2.2、Source code analysis

launch file

py code:~/transbot_ws/src/transbot_laser/scripts/laser_Avoidance.py

According to the obstacle, the position of appearance, set up the different state of the trolley.

Source code parameter analysis:

ParameterDefaults valueJudgment
self.front_warningDefaults is 0When the value is greater than 10, there is an obstacle ahead.
self.Left_warningDefaults is 0When the value is greater than 10, there is an obstacle in the front left.
self.Right_warningDefaults is 0When the value is greater than 10, there is an obstacle in the front right.